package lab02.test19;

public class Test {
    public static void main(String[] args) {
        //编写一个程序，实现字符串的大小写转换并倒序输出
        // 如输入为“HelloWord”，输出为“DROwOLLEH”

        String result = "Hello World!";
        StringBuffer stringBuffer = new StringBuffer();//将字符串装在stringBuffer中

        for (int i = 0; i < result.length(); i++) {
            char tmp = result.charAt(i);
            if (tmp >= 'A' && tmp <= 'Z') {
                // System.out.print((char)(tmp+32));
                stringBuffer.append((char)(tmp+32)); //追加：将大写变小写
            } else if (tmp >= 'a' && tmp <= 'z') {
                //System.out.print((char)(tmp-32));
                stringBuffer.append((char) (tmp - 32)); //追加：将小写变大写
            } else {
                //System.out.print(tmp);
                stringBuffer.append(tmp);//追加：
            }//符号等原型输出
        }
        System.out.println(stringBuffer.reverse());
    }

}
